
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define max(x,y) (((x) > (y)) ? (x) : (y))  

#define min(x,y) (((x) < (y)) ? (x) : (y))  

void _RGB2HSV(int red, int green, int blue, int * hue, int * saturation, int * value);
void _HSV2RGB(int hue, int saturation, int value, int * red, int * green, int * blue);


void iPhonePhotoFilterPastels(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoRotate(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int n);
void iPhonePhotoLaplace(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV0(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoSobelFilter5x5_x(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoBrightFilterByHDR(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoGrayFilter1(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int value);
void iPhonePhotoPaperFilter1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoGrayFilter2(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoTestFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoBrightFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoContastFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoContastFilter1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoOliFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV03(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV03_1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoInvertFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoSharpFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoKirschFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoBinaryFilterGray1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoBinaryFilterGray2(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMotionBlurFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoOliFilter2(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoDarkenFilterByHDR(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV01(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV04(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoOverlayFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV05(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int value);
void iPhonePhotoFilterLV05_2(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV05_3(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoHDRFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoHDRFilter1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoBiningFilter3(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoBiningFilter2(unsigned char* pSrc,unsigned int width,unsigned int height);
unsigned char* iPhonePhotoThumbBottonFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoHistoEqual(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoTestLoMoFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoThumbClickedFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhoto8bitColor(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhoto8bitColorG(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhoto16bitColor(unsigned char* pSrc,unsigned int width,unsigned int height);
///	iPhonePhotoMedianFilter9x9(Image.pSrc,Image.Width,Image.Height);
void iPhonePhotoMedianFilter9x9(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMedianFilter5x5(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoPrewittFilter1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoPrewittFilter2(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV06(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV06_1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV06_2(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterTest(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoDarkenByGray(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMedianFilter5x5G(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMedianFilterG(unsigned char* pSrc,unsigned int width,unsigned int height);
unsigned short* iPhonePhotoGroup(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV6(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMotionRoughFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoFilterLV07(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMosaic(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int value);
void iPhonePhotoCenter(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int ef);
void iPhonePhotoLv09Filter(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int value);
void iPhonePhotoLv10Filter(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int value);
void iPhonePhotoLv16Filter(unsigned char* pSrc, unsigned int width,unsigned int height,unsigned int value);
/*
  1  2  1
  
  0  0  0

 -1 -2 -1
 
  1  0 -1
 
  2  0 -2
 
  1  0 -1
 */
void iPhonePhotoOldMovie(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned int value);
void iPhonePhotoGFilter1(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoSobelFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
/*
 1 2 1
 2 2 2
 1 2 1
 */
void iPhonePhotoGaussianFilter(unsigned char* pSrc,unsigned int width,unsigned int height);

/*
 1 1 1
 1 1 1
 1 1 1
 */
void iPhonePhotoMeanFilter(unsigned char* pSrc,unsigned int width,unsigned int height);

void iPhonePhotoMeanFilter5x5_x(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoMeanFilter5x5(unsigned char* pSrc,unsigned int width,unsigned int height);
/*주변의 8개와 자기자신을 포함해서 중앙값을 선택합니다. */
void iPhonePhotoMedianFilter(unsigned char* pSrc,unsigned int width,unsigned int height);

void iPhonePhotoToneFilter(unsigned char* pSrc,unsigned int width,unsigned int height,unsigned char R,unsigned char G,unsigned char B);

void iPhonePhotoPrewittFilter(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoGaussianFilter5x5_x(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhotoSpecialGaussianFilter(unsigned char* pSrc,unsigned int width,unsigned int height);

void iPhonePhoto1to4(unsigned char* pSrc,unsigned int width,unsigned int height);
void iPhonePhoto4to1(unsigned char* pSrc,unsigned int width,unsigned int height);

void iPhonePhotoHeatMapFilter(unsigned char* pSrc,unsigned int width,unsigned int height);

void iPhonePhotoNeon(unsigned char* pSrc,unsigned int width,unsigned int height,double Value);